package com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyActivity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.util.http.HttpClient;
import com.diudiutechnology.www.yadiudiu.util.http.JsonTools;
import com.diudiutechnology.www.yadiudiu.util.utils.Constant;
import com.diudiutechnology.www.yadiudiu.util.utils.ImgUtils;
import com.diudiutechnology.www.yadiudiu.util.utils.MyProgressDialog;
import com.diudiutechnology.www.yadiudiu.util.utils.PermissionsChecker;
import com.diudiutechnology.www.yadiudiu.util.utils.PictureUtil;
import com.diudiutechnology.www.yadiudiu.util.utils.SelectPhotoPop;
import com.diudiutechnology.www.yadiudiu.util.utils.Sundry;
import com.diudiutechnology.www.yadiudiu.util.utils.ToastUtils;
import com.diudiutechnology.www.yadiudiu.util.utils.UserInfoUtils;
import com.diudiutechnology.www.yadiudiu.util.view.UniversalPhotoPop;
import com.diudiutechnology.www.yadiudiu.yadiudiu.main.MyActivity.BaseActivity;
import com.diudiutechnology.www.yadiudiu.yadiudiu.main.MyActivity.LoginActivity;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.AddThePropertyModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.CommodityManagementModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.MerchantsTypeModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.MineFragmentModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.UniversalModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.main.MyApplication;
import com.diudiutechnology.www.yadiudiu.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import org.xutils.common.Callback;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.finalteam.galleryfinal.GalleryFinal;
import cn.finalteam.galleryfinal.model.PhotoInfo;

/**
 * Created by Administrator on 2017/9/2.
 * 添加楼盘 买房
 */

public class AddThePropertyActivity extends BaseActivity implements View.OnClickListener, Callback.CommonCallback<String> {
    @Bind(R.id.retur)
    LinearLayout retur;
    @Bind(R.id.label_deleteLayout)//清空标签
            LinearLayout label_deleteLayout;

    @Bind(R.id.posted_layout)//图片
            RelativeLayout posted_layout;
    @Bind(R.id.modification)//图片
            RelativeLayout modification;
    @Bind(R.id.modificon_img)//图片
            ImageView modificon_img;

    @Bind(R.id.modification_text)//图片数量
            TextView modification_text;
    @Bind(R.id.rent_way_text)//选择地址
            TextView rent_way_text;

    @Bind(R.id.label)//标签
            EditText label;
    @Bind(R.id.add)//添加标签
            Button add;
    @Bind(R.id.label_add_label)//标签的展示
            LinearLayout label_add_label;

    @Bind(R.id.fitment_text)//装修
            TextView fitment_text;
    @Bind(R.id.toward_text)//朝向
            TextView toward_text;
    @Bind(R.id.floor_text)//建与
            TextView floor_text;
    @Bind(R.id.use_text)//用途
            TextView use_text;
    @Bind(R.id.built_in_text)//建筑类型
            TextView built_in_text;
    @Bind(R.id.community_text)//户型面积
            TextView community_text;

    @Bind(R.id.title_text)//楼盘名称
            EditText title_text;
    @Bind(R.id.monthly_rent_text)//售价
            EditText monthly_rent_text;

    @Bind(R.id.payment_text)//规划户数
            EditText payment_text;
    @Bind(R.id.type_text)//年限
            EditText type_text;

    @Bind(R.id.property_compan)//物业公司
            EditText property_compan;
    @Bind(R.id.afforestation)//绿化
            EditText afforestation;
    @Bind(R.id.parking_spaces)//车位
            EditText parking_spaces;
    @Bind(R.id.plot)//容积
            EditText plot;

    @Bind(R.id.title_center)
    TextView title_center;

    @Bind(R.id.button)//提交
            Button button;
    Context context;

    String pos = "0"; //0、添加商品  1、修改商品 2、展示商品
    String u_id = "";//商家ID  pos=0时 u_id 为店铺id
    String id = "";
    String merchanttype = "";//类型
    private MyProgressDialog mDialog;
    String Judge_interface = "0";//判断哪个接口   0、上传,修改 1获取数据、
    int Judge_img = 0;//图片是否点击 和 类型是否点击

    int Judge = 0;//0、装修 1、朝向 2、建与 3、用途 4、建筑类型 5、户型面积
    private View viewkre;
    private SelectPhotoPop selectPhotoPop;
    private DisplayImageOptions options;
    private ImageLoader imageLoader;
    List<CommodityManagementModel> buycarlist = new ArrayList<>();
    List<UniversalModel> unit = new ArrayList<>();//分类选项
    List<String> labellist = new ArrayList<>();//标签数组
    String labellings = "";//标签
    int ints = 0;
    String posted = "";//图片
    String province = "";//省
    String city = "";// 市
    String area = "";//  区
    String longitude = "";//   经度
    String latitude = "";//  纬度

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewkre = View.inflate(this, R.layout.activity_add_the_property, null);
        setContentView(viewkre);
        ButterKnife.bind(this);
        context = this;
        initView();
    }

    private void initView() {
        retur.setOnClickListener(this);

        posted_layout.setOnClickListener(this);
        rent_way_text.setOnClickListener(this);
        add.setOnClickListener(this);
        fitment_text.setOnClickListener(this);
        toward_text.setOnClickListener(this);
        floor_text.setOnClickListener(this);
        use_text.setOnClickListener(this);
        built_in_text.setOnClickListener(this);
        community_text.setOnClickListener(this);
        button.setOnClickListener(this);
        label_deleteLayout.setOnClickListener(this);
        modificon_img.setOnClickListener(this);
        MineFragmentModel mineFragmentModel = UserInfoUtils.readUserInfo(this);
        merchanttype = mineFragmentModel.getMerchanttype();

        options = ImgUtils.imageOptions();
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(context));
        if (getIntent() != null) {
            pos = getIntent().getStringExtra("pos");
            u_id = getIntent().getStringExtra("u_id");
            if (!pos.equals("0")) {
                id = getIntent().getStringExtra("id");
            }
        }
        if (pos.equals("1")) {
            title_center.setText("修改商品");
            button.setText("修改");
            processdetails();
        } else if (pos.equals("2")) {
            title_center.setText("商品详情");
            button.setVisibility(View.GONE);
            processdetails();
            Judge_img = 1;
          processnNotEdit();
        }
    }



    //不可编辑
    public void processnNotEdit() {
        label.setEnabled(false);
        plot.setEnabled(false);
        parking_spaces.setEnabled(false);

        title_text.setEnabled(false);
        monthly_rent_text.setEnabled(false);
        payment_text.setEnabled(false);

        type_text.setEnabled(false);
        property_compan.setEnabled(false);
        afforestation.setEnabled(false);

    }

    public void TextViewAddSet(String Str) {
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
        // 实例化Text
        TextView textView = new TextView(this);
        params.setMargins(5, 5, 5, 5);
        textView.setLayoutParams(params);
        textView.setGravity(Gravity.CENTER);
        textView.setText(Str);
        textView.setTextSize(14);
        textView.setPadding(20, 10, 20, 10);
        textView.setTextColor(getResources().getColor(R.color.white));
        textView.setBackgroundResource(R.drawable.demand_other_label_bg_shape);

        label_add_label.addView(textView);
        label.setText("");
        labellist.add(labellist.size(), Str);
    }

    //绑定选项
    private void processunit() {
        UniversalPhotoPop typephoto = null;
        if (Judge==5){
            typephoto = new UniversalPhotoPop(context, unit,unit,1);
        }else {
             typephoto = new UniversalPhotoPop(context, unit, 1);
        }


        typephoto.showAtLocation(viewkre, Gravity.BOTTOM, 0, 0);
        typephoto.setAddresskListener(new UniversalPhotoPop.OnAddressCListener() {
            @Override
            public void onClick(String province, String city, String area) {

                if (Judge == 0) {
                    fitment_text.setText(province);
                } else if (Judge == 1) {
                    toward_text.setText(province);
                } else if (Judge == 2) {
                    floor_text.setText(province);
                } else if (Judge == 3) {
                    use_text.setText(province);
                } else if (Judge == 4) {
                    built_in_text.setText(province);
                } else if (Judge == 5) {
                  int prov=Integer.valueOf(province);
                  int cit=Integer.valueOf(city);
                    if (prov>cit){
                        ToastUtils.show(context, getResources().getString(R.string.please_communitys));
                        return;
                    }
                    community_text.setText(province+"-"+city);
                }
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.retur:
                finish();
                break;
            case R.id.posted_layout://添加照片
                if (Judge_img == 0) {
                    if (!PermissionsChecker.getPermissionsChecker(this, "0", 0)) {
                        if (!PermissionsChecker.getPermissionsChecker(this, "0", 2)) {
                            showSelectPicPop();
                        } else {
                            ToastUtils.show(context, "请检查是否打开储存权限");
                        }
                    } else {
                        ToastUtils.show(context, "请检查是否打开相机权限");
                    }
                }
                break;

            case R.id.modificon_img://选择图片
                if (Judge_img == 0) {
                    Intent intent = new Intent(context, GeneralPictureEditorActivity.class);
                    intent.putExtra("pos", "1");
                    intent.putExtra("Judge_posstr", "1");
                    intent.putExtra("conumg", posted);
                    startActivityForResult(intent, Constant.ADDHOUSE);
                }
                break;
            case R.id.rent_way_text://选择地址
                if (Judge_img == 0) {
                    Intent intent = new Intent(context, SelectTheAddressActivity.class);
                    intent.putExtra("pos", "3");
                    startActivityForResult(intent, Constant.ADDADDRESSHOUSE);
                }
                break;
            case R.id.fitment_text://装修
                if (Judge_img == 0) {
                    Judge = 0;
                    unit.clear();
                    String[] names = getResources().getStringArray(R.array.fitment);
                    UniversalModel model;
                    for (int i = 0; i < names.length; i++) {
                        model = new UniversalModel();
                        model.setName(names[i]);
                        unit.add(model);
                    }
                    processunit();
                }
                break;
            case R.id.toward_text://朝向
                if (Judge_img == 0) {
                    Judge = 1;
                    unit.clear();
                    String[] names = getResources().getStringArray(R.array.toward);
                    UniversalModel model;
                    for (int i = 0; i < names.length; i++) {
                        model = new UniversalModel();
                        model.setName(names[i]);
                        unit.add(model);
                    }
                    processunit();
                }
                break;
            case R.id.floor_text://建于
                if (Judge_img == 0) {
                    Judge = 2;
                    unit.clear();
                    UniversalModel model;
                    Calendar c = Calendar.getInstance();//
                    int year = c.get(Calendar.YEAR);
                    for (int i = year + 20; i > 1940; i--) {
                        System.out.println("stringmd5result=" + i);
                        model = new UniversalModel();
                        model.setName(i + "");
                        unit.add(model);
                    }
                    processunit();
                }
                break;
            case R.id.use_text://用途
                if (Judge_img == 0) {
                    Judge = 3;
                    unit.clear();
                    String[] names = getResources().getStringArray(R.array.use);
                    UniversalModel model;
                    for (int i = 0; i < names.length; i++) {
                        model = new UniversalModel();
                        model.setName(names[i]);
                        unit.add(model);
                    }
                    processunit();
                }
                break;
            case R.id.built_in_text://建筑类型
                if (Judge_img == 0) {
                    Judge = 4;
                    unit.clear();
                    String[] names = getResources().getStringArray(R.array.built);
                    UniversalModel model;
                    for (int i = 0; i < names.length; i++) {
                        model = new UniversalModel();
                        model.setName(names[i]);
                        unit.add(model);
                    }
                    processunit();
                }
                break;
            case R.id.community_text://户型
                if (Judge_img == 0) {
                    Judge = 5;
                    unit.clear();
                    UniversalModel model;
                    for (int i = 1; i < 501; i++) {
                        model = new UniversalModel();
                        model.setName(i+"");
                        unit.add(model);
                    }
                    processunit();
                }
                break;

            case R.id.add://标签
                if (Judge_img == 0) {
                    if (TextUtils.isEmpty(label.getText().toString().trim())) {//标签
                        ToastUtils.show(context, getResources().getString(R.string.please_label));
                        return;
                    }
                    for (int i = 0; i < label_add_label.getChildCount(); i++) {
                        if (label.getText().toString().trim().equals(((TextView) label_add_label.getChildAt(i))
                                .getText().toString())) {
                            // 标签重复
                            ToastUtils.show(context, getResources().getString(R.string.please_label_repeat));
                            return;
                        }
                    }
                    if (label_add_label.getChildCount() > 6) {
                        ToastUtils.show(context, getResources().getString(R.string.label_repeat));
                        return;
                    }
                    TextViewAddSet(label.getText().toString().trim());
                }
                break;

                          /* 注释  相机*/
            case R.id.item_popupwindows_camera:
                selectPhotoPop.dismiss();
                GalleryFinal.openCamera(Constant.CAMERA, MyApplication.getInstance().initGalley(Constant.CAMERA, 1), mOnHanlderResultCallback);
                break;
            /* 注释  相册*/
            case R.id.item_popupwindows_Photo:
                selectPhotoPop.dismiss();
                GalleryFinal.openGallerySingle(Constant.GALLERYSINGLE, MyApplication.getInstance().initGalley(Constant.GALLERYSINGLE, 1), mOnHanlderResultCallback);
                break;
            /* 注释  取消*/
            case R.id.item_popupwindows_cancel:
                selectPhotoPop.dismiss();
                break;
            case R.id.label_deleteLayout://清空标签
                label_add_label.removeAllViews();
                labellist.clear();
                labellings = "";
                break;
            case R.id.button:
                if (labellist.size() > 0) {
                    for (int i = 0; i < labellist.size(); i++) {
                        if (labellings.equals("")) {
                            labellings = labellist.get(i);
                        } else {
                            labellings = labellings + "|" + labellist.get(i);
                        }
                    }
                }
                if (TextUtils.isEmpty(posted)) {//楼盘图片
                    ToastUtils.show(context, getResources().getString(R.string.please_building_img));
                    return;
                }
                if (TextUtils.isEmpty(title_text.getText().toString().trim())) {//楼盘
                    ToastUtils.show(context, getResources().getString(R.string.please_building_name));
                    return;
                }
                if (TextUtils.isEmpty(rent_way_text.getText().toString().trim())) {//楼盘地址
                    ToastUtils.show(context, getResources().getString(R.string.please_building_address));
                    return;
                }
                if (TextUtils.isEmpty(monthly_rent_text.getText().toString().trim())) {//楼盘售价
                    ToastUtils.show(context, getResources().getString(R.string.please_building_monthly));
                    return;
                }
                if (TextUtils.isEmpty(payment_text.getText().toString().trim())) {//户数
                    ToastUtils.show(context, getResources().getString(R.string.please_building_payment));
                    return;
                }
                if (TextUtils.isEmpty(fitment_text.getText().toString().trim())) {//装修
                    ToastUtils.show(context, getResources().getString(R.string.please_building_fitment));
                    return;
                }
                if (TextUtils.isEmpty(toward_text.getText().toString().trim())) {//方向
                    ToastUtils.show(context, getResources().getString(R.string.please_building_toward));
                    return;
                }
                if (TextUtils.isEmpty(floor_text.getText().toString().trim())) {//建于
                    ToastUtils.show(context, getResources().getString(R.string.please_building_floor));
                    return;
                }
                if (TextUtils.isEmpty(use_text.getText().toString().trim())) {//用途
                    ToastUtils.show(context, getResources().getString(R.string.please_building_use));
                    return;
                }
                if (TextUtils.isEmpty(type_text.getText().toString().trim())) {//产权年限
                    ToastUtils.show(context, getResources().getString(R.string.please_building_type));
                    return;
                }
                if (TextUtils.isEmpty(built_in_text.getText().toString().trim())) {//建筑类型
                    ToastUtils.show(context, getResources().getString(R.string.please_building_built));
                    return;
                }
                if (TextUtils.isEmpty(property_compan.getText().toString().trim())) {//物业公司
                    ToastUtils.show(context, getResources().getString(R.string.please_building_property));
                    return;
                }
                if (TextUtils.isEmpty(afforestation.getText().toString().trim())) {//绿化率
                    ToastUtils.show(context, getResources().getString(R.string.please_building_afforestation));
                    return;
                }
                if (TextUtils.isEmpty(parking_spaces.getText().toString().trim())) {//车位
                    ToastUtils.show(context, getResources().getString(R.string.please_building_parking_spaces));
                    return;
                }
                if (TextUtils.isEmpty(plot.getText().toString().trim())) {//容积
                    ToastUtils.show(context, getResources().getString(R.string.please_building_plot));
                    return;
                }
                if (TextUtils.isEmpty(community_text.getText().toString().trim())) {//户型建面区间
                    ToastUtils.show(context, getResources().getString(R.string.please_building_community));
                    return;
                }
                if (TextUtils.isEmpty(labellings)) {//标签
                    ToastUtils.show(context, getResources().getString(R.string.please_label));
                    return;
                }
                processBridalchamber();
                break;

        }
    }

    private GalleryFinal.OnHanlderResultCallback mOnHanlderResultCallback = new GalleryFinal.OnHanlderResultCallback() {
        @Override
        public void onHanlderSuccess(int reqeustCode, List<PhotoInfo> resultList) {
            Bitmap bitmap = PictureUtil.decodeSampledBitmapFromFile(resultList.get(0).getPhotoPath(), Constant.WIDE, Constant.WIDE);
            String conimg = PictureUtil.saveBitmapFile(bitmap, String.valueOf(0));
            Intent intent = new Intent(context, GeneralPictureEditorActivity.class);
            intent.putExtra("pos", "1");
            intent.putExtra("Judge_posstr", "0");
            intent.putExtra("conumg", conimg);
            startActivityForResult(intent, Constant.ADDHOUSE);

        }

        @Override
        public void onHanlderFailure(int requestCode, String errorMsg) {

        }
    };

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        System.out.println("stringmd5result=" + requestCode + "resultCode=" + resultCode);

        if (resultCode == Constant.ADDHOUSE) {

            posted = data.getStringExtra("posted");//图片集合
            String conumg = data.getStringExtra("conumg");// 首图
            String number = data.getStringExtra("number");// 首图
            if (TextUtils.isEmpty(posted)) {
                posted_layout.setVisibility(View.VISIBLE);
                modification.setVisibility(View.GONE);
            } else {
                posted_layout.setVisibility(View.GONE);
                modification.setVisibility(View.VISIBLE);
                imageLoader.displayImage(Constant.HTTP + conumg, modificon_img, options);
                modification_text.setText("编辑图片(" + number + "/6)");
            }
        } else if (resultCode == Constant.ADDADDRESSHOUSE) {
            //  specific_address.setText(data.getStringExtra("address"));
            province = data.getStringExtra("province");//省
            city = data.getStringExtra("city");// 市
            area = data.getStringExtra("district");//  区
            longitude = data.getStringExtra("longitude");//   经度
            latitude = data.getStringExtra("latitude");//  纬度
            rent_way_text.setText(province + city + area + data.getStringExtra("address"));
        }
    }

    //相册
    private void showSelectPicPop() {
        selectPhotoPop = new SelectPhotoPop(this, this);
        selectPhotoPop.showAtLocation(viewkre, Gravity.BOTTOM, 0, 0);
    }

    //展示产品详情
    private void processdetails() {
        if (Sundry.isOpenNetwork(context)) {
            Judge_interface="1";
            mDialog = new MyProgressDialog(context);
            HttpClient.details(id,"","",this);
        }else {
            ToastUtils.Toastshow(context, getResources().getString(R.string.network));
        }
    }
    //提交
    private void processBridalchamber() {
        if (Sundry.isOpenNetwork(context)) {
            Judge_interface="0";
            mDialog = new MyProgressDialog(context);
            String Data = "";
            if (pos.equals("0")) {
                Data = Constant.BRIDALCHAMBERRENTAL;
            } else if (pos.equals("1")) {
                Data = Constant.BRIDALCHAMBEREDITHOMEL;
            }
            HttpClient.Bridalchamber(Data, pos, id, u_id, posted, title_text.getText().toString().trim(), use_text.getText().toString().trim(), monthly_rent_text.getText().toString().trim()
                    , fitment_text.getText().toString().trim(), toward_text.getText().toString().trim(),
                    payment_text.getText().toString().trim(), rent_way_text.getText().toString().trim(), floor_text.getText().toString().trim(),
                    type_text.getText().toString().trim(), built_in_text.getText().toString().trim(), property_compan.getText().toString().trim()
                    , labellings, afforestation.getText().toString().trim(), longitude, latitude, parking_spaces.getText().toString().trim()
                    , plot.getText().toString().trim(), community_text.getText().toString().trim(), this);
        } else {
            ToastUtils.Toastshow(context, getResources().getString(R.string.network));
        }
    }

    @Override
    public void onSuccess(String result) {
        if (mDialog != null) {
            mDialog.dismiss();
        }

        System.out.println("stringmd5result" + result);
        List<MerchantsTypeModel> getmerchanttype = JsonTools.getmerchanttype(result);
        if (getmerchanttype != null || getmerchanttype.size() > 0) {
            String status = getmerchanttype.get(0).getError();
            String getMsg = getmerchanttype.get(0).getMssage();
            if (status.equals("200")) {
                if (Judge_interface.equals("0")){
                    finish();
                }else {
                    String result1 = getmerchanttype.get(0).getResult();
                   List<AddThePropertyModel> getdetails = JsonTools.getdetails(result1);
                    if (getdetails != null || getdetails.size() > 0) {
                        List<AddThePropertyModel> getdetailslist = JsonTools.getdetailslist(getdetails.get(0).getList());
                        if (getdetailslist != null || getdetailslist.size() > 0) {
                            processData(getdetailslist);
                        }
                    }
                }
            } else if (status.equals("105")) {
                Intent intent = new Intent(context, LoginActivity.class);
                startActivity(intent);
                ToastUtils.show(context, getMsg);
            } else {
                ToastUtils.show(context, getMsg);
            }
        }
    }

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        if (mDialog != null) {
            mDialog.dismiss();
        }

        System.out.println("stringmd5result" + ex.getMessage().toString());
        ToastUtils.Toastshow(context, getResources().getString(R.string.server));
    }

    @Override
    public void onCancelled(CancelledException cex) {
        if (mDialog != null) {
            mDialog.dismiss();
        }

        System.out.println("stringmd5result" + cex.getMessage().toString());
        ToastUtils.Toastshow(context, getResources().getString(R.string.server));
    }

    @Override
    public void onFinished() {

    }
    //绑定数据
    private void processData( List<AddThePropertyModel> getdetailslist ){
        AddThePropertyModel addThePropertyModel = getdetailslist.get(0);
        if (!addThePropertyModel.getHomepic().equals("")){
            String[] split = addThePropertyModel.getHomepic().split("\\|");
            imageLoader.displayImage(Constant.HTTP + split[0], modificon_img, options);
            modification_text.setText("编辑图片(" + split.length + "/6)");
            posted=addThePropertyModel.getHomepic();
            posted_layout.setVisibility(View.GONE);
            modification.setVisibility(View.VISIBLE);
        }
        title_text.setText(addThePropertyModel.getTitle());
        rent_way_text.setText(addThePropertyModel.getAddress());
        monthly_rent_text.setText(addThePropertyModel.getPrice());
        payment_text.setText(addThePropertyModel.getProfile());
        fitment_text.setText(addThePropertyModel.getFitmentfinish());
        toward_text.setText(addThePropertyModel.getOrientation());
        floor_text.setText(addThePropertyModel.getQuotationtime());
        use_text.setText(addThePropertyModel.getType());
        type_text.setText(addThePropertyModel.getOtherstime());
        built_in_text.setText(addThePropertyModel.getCturetype());
        property_compan.setText(addThePropertyModel.getLayout());
        afforestation.setText(addThePropertyModel.getGreeningrate());
        parking_spaces.setText(addThePropertyModel.getCarport());
        plot.setText(addThePropertyModel.getPlotratio());
        community_text.setText(addThePropertyModel.getQujian());
        longitude=addThePropertyModel.getLongitude();
        latitude=addThePropertyModel.getLatitude();

        if (!addThePropertyModel.getLabelling().equals("")){
            String[] splits = addThePropertyModel.getLabelling().split("\\|");
            for (int i=0;i<splits.length;i++){
                TextViewAddSet(splits[i]);
            }
            labellings=addThePropertyModel.getLabelling();
        }
    }
}



